cmake_minimum_required(VERSION 3.0)
project(esvr)

set(PLATFORM x86)
if(WIN32)
	ADD_DEFINITIONS(-DLUA_USE_WIN)
elseif(UNIX)
	ADD_DEFINITIONS(-DLUA_USE_LINUX)
elseif(APPLE)
	ADD_DEFINITIONS(-DLUA_USE_MACOSX)
endif()



set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -std=c++11 -fPIC")

aux_source_directory(lua-5.3.2/src LUA_SRC)

add_library(lua ${LIB_TYPE} ${LUA_SRC})
if(UNIX)
	target_link_libraries(lua -ldl)
    set_property(TARGET lua PROPERTY COMPILE_FLAGS "-fPIC")
endif()

if(MSVC)
	ADD_DEFINITIONS(-DLUA_BUILD_AS_DLL)
	ADD_DEFINITIONS(-DLUA_LIB)
endif()

set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -std=c++11 -fPIC")
include_directories(lua-5.3.2/src)
add_library(mylib SHARED "extends/test_extend.cpp")
target_link_libraries(mylib lua)
